<?php
	defined( '_JEXEC' ) or die( 'Restricted access' );
?>

<link href="<?php echo JURI::base(true)?>/administrator/components/com_wrd/assets/css/jquery.autocomplete.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="<?php echo JURI::base(true)?>/administrator/components/com_wrd/assets/js/jquery-migrate-1.1.1.min.js"></script>
<script type="text/javascript" src="<?php echo JURI::base(true)?>/administrator/components/com_wrd/assets/js/jquery.autocomplete.js"></script>

<script type="text/javascript">
	jQuery(document).ready(function()
	{
		jQuery("#company_name").autocomplete("<?php echo JRoute::_("index.php?option=com_wrd&task=getCompanies", false)?>", {
		    width: 260,
		    matchContains: true,
		    minChars: 1,
		    selectFirst: false
		});
	
	});
	

var sectioncountrys = new Array();	
<?php		
foreach ($this->lists['countryToCity'] as $k=>$item)
 {			
	echo "sectioncountrys[".$k."] = new Array( '$item->country_id','".addslashes( $item->id )."','".addslashes( $item->name )."' );\n\t\t";		
 }	
 ?>	var sectioncitys = new Array();	
 <?php		
 foreach ($this->lists['cityToDistric'] as $k=>$item) {			
 echo "sectioncitys[".$k."] = new Array( '$item->city_id','".addslashes( $item->id )."','".addslashes( $item->name )."' );\n\t\t";		
 }	?>	
 
 function changeCity( listname, source, key, orig_key, orig_val) {
 	var list = eval( 'document.default_registration_form.' + listname );		
 	// empty the list		
 	for (i in list.options.length) 
 	{
 		list.options[i] = null;		
 	}		
	 var i = 0;		
	 var j = 0;		
	 for (x in source) {			
 		if (source[x][0] == key) {	
 			opt = new Option();				
 			opt.value = source[x][1];				
 			opt.text = source[x][2];				
 			if ((orig_key == key && orig_val == opt.value) || i == 0) {					
 				opt.selected = true;					
 				j = opt.value;				
 			}				
 		
 			list.options[i++] = opt;			
 			
 			}		
 	}		
 	
 	if(i == 0){			
 		opt = new Option();			
 		opt.value = 0;			
 		opt.text = '<?php echo JText::_('WRD_OPT_SELECT_CITY') ?>';			
 		opt.selected = true;			
 		list.options[i++] = opt;		
 	}		
 	
 	list.length = i;		
 	if(listname == 'c_city'){			
 		changeDistric('c_distric' ,sectioncitys,j,0,0);		
 	}	
 	
 	}	
 	
 	function changeDistric( listname , source, key, orig_key, orig_val){		
 		var list = eval( 'document.default_registration_form.' + listname );		
 		for (i in list.options.length) {			
 			list.options[i] = null;		
 		}		
 		
 		var i = 0;		
 		for (x in source) {			
 			if (source[x][0] == key) {				
 				opt = new Option();				
 				opt.value = source[x][1];				
 				opt.text = source[x][2];				
 				if ((orig_key == key && orig_val == opt.value) || i == 0) {					
 					opt.selected = true;				
 				}				
 				
 				list.options[i++] = opt;			
 				
 				}		
 			}		
 			
 			if(i == 0){			
 				opt = new Option();			
 				opt.value = 0;			
 				opt.text = '<?php echo JText::_('WRD_OPT_SELECT_DISTRICT') ?>';			
 				opt.selected = true;			
 				list.options[i++] = opt;		
 			}		
 		
 		list.length = i;	
 		}
 		
 		function showOther(ex,id){		
 			vl = document.getElementById(ex).value;		
 			if(vl=="other"){			
 				document.getElementById(id).style.display = '';			
 				
 			}else{			
 				document.getElementById(id).style.display = 'none';		
 			}	
 		}
 </script>

 
 
<div class="row">
	<h2 class="all_reward_header"><?php echo JText::_('WRD_PROFILE_PROFILE')?></h2>
	<div id="profile" class="twelve columns">
<div style="clear: right ; height:0px;">&nbsp;</div>
	<table id="table1" width="100%" cellpadding="5" cellspacing="0" align="center">
		<tr>
			<td class="a-left title">
				<div><label for="title"><h2><?php echo JText::_('WRD_PROFILE_ACCOUNT_PREFERENCE')?></h2></label></div>
				<div class="contenttt">
                	<div class="left">
                        <strong style="color:#3E3061;"><?php echo $this->data->name_on_card; ?></strong><br>
                       	<?php echo JText::_('WRD_PROFILE_ACCOUNT_NUM')?> <strong style="color:#3E3061;"> <?php echo substr($this->data->member_id,1); ?></strong>
                        <label for="title">
                        	<?php echo JText::_('WRD_PROFILE_BALANCE')?>
                        	 : <span class='link_color'>
                        	  <?php echo number_format($this->p_o_u->point,0,'.',',') ;?>
                        	<?php echo JText::_('WRD_PROFILE_POINTS')?> </span></label>
                    </div>
                    <div class="right">
                        <a href="<?php echo JRoute::_('index.php?option=com_wrd&view=profile&layout=myaccount&Itemid=119') ?>"><?php echo JText::_('WRD_PROFILE_VIEW_THE_SUMMARY_OF_YOUR_POINTS')?></a>
                    </div>
                </div>
			</td>
		</tr>
	</table>  
<table cellpadding="0" cellspacing="0" id="table2" >    	
<tr>	    
	<?php	    	
	if($this->data->user_id != 0)    	
	{    		
		$step = $this->data->step;    		if($step > 1):               
	 	$pointstep = WrdHelper::totalPointOfEachStep($step);         
	endif;    		    		
	
	switch ($step){
	case 1:  
	?>  
	 	<td>
	 		<div class="radius progress success">
	 			<span class="meter" style="width: 20%; float:left;"></span>
	 			<span class="meterload"><?php echo JText::_('WRD_PROFILE_PLEASE_FILL_ALL_FILEDS_OF_THIS_STEP')?></span></div></td>  				   			
	<?php    			
	break;    			
	case 2:    			
	?>   
	<td>
		<div class="radius progress success">
			<span class="meter" style="width: 40%; float:left;"></span>
			<span class="meterload"><?php echo JText::_('WRD_PROFILE_POINT_REWARDS_IS_COMMING_TO_YOUR_ACCOUNT_BY_THIS_STEP')?></span>
		</div>
	</td>   				   			
	<?php    				
	break;    			
	case 3:    			
	?> 
	<td>
		<div class="radius progress success">
			<span class="meter" style="width: 60%; float:left;"></span>
			<span class="meterload"><?php echo JText::_('WRD_PROFILE_POINTS_REWARDS')?></span>
		</div>
	</td>			
	<?php    				
	break;    			
	case 4:    			
	?> 
	<td>
		<div class="radius progress success">
			<span class="meter" style="width: 80%; float:left;"></span>
			<span class="meterload"><?php echo JText::_('WRD_PROFILE_POINTS_AND_FINISH')?></span></div></td>  			
	<?php    				
	break;    			
	case 5:    			
	?> 
	<td>
		<div class="radius progress success">
			<span class="meter" id="meter100" style="width: 100%; float:left;">
	   	 		<?php echo JText::_('WRD_PROFILE_CONGRATULATION_100_DONE')?> 
	   	 		
			</span>
		</div>
	</td>			
	<?php
	break;    		
	}    	
}   
?>
</tr>
</table>	
     <form onsubmit="return checkForm(this);" id="profile-registration" name="default_registration_form" class="form-validate" method="post" action="<?php echo JRoute::_('index.php?option=com_wrd&task=profile.save'); ?>">	
     <table width="100%" id="default_registration_form" cellpadding="5" cellspacing="0" class="tblfrm">		
     <tr>			
     <td colspan="2" height="30">                
     	<dl class="tabs">
			<dd>
				<a href="<?php echo JRoute::_('index.php?option=com_wrd&view=profile&layout=default&id=1&Itemid=170') ?>">
					<?php echo JText::_('WRD_PROFILE_BASIC_INFOMATION') ?>
				</a>
			</dd>
			<dd>
				<a href="<?php echo JRoute::_('index.php?option=com_wrd&view=profile&layout=default&id=2&Itemid=170') ?>">
					<?php echo JText::_('WRD_PROFILE_PERSONAL_INFOMATION') ?>
				</a>
			</dd>
			<dd class="active"><?php echo JText::_('WRD_PROFILE_BIZ_CONTACT') ?></dd>
			<dd class="hide-for-small">
				<a href="<?php echo JRoute::_('index.php?option=com_wrd&view=profile&layout=default&id=4&Itemid=170') ?>">
					<?php echo JText::_('WRD_PROFILE_PROFESSIONALISM') ?>
				</a>
			</dd>
		</dl>
     </td>		
  </tr>		
  <tr>
  <td>
<table width="90%" align="center" id="table1_02">
	<div class="reg_tips" >
		<div class="reg_tip_content">
			<p><?php echo JText::_('WRD_PROFILE_THE_FILEDS') ?><b style="color: #FF0000 ; padding: 0px 5px ;">*</b> <?php echo JText::_('WRD_PROFILE_ARE') ?> <b style="color: #FF0000 ; padding: 0px 5px ;"><?php echo JText::_('WRD_PROFILE_REQUIRED') ?></b>.</p>
			<?php echo JText::_('WRD_PROFILE_STEP3_FILLING_ALL_FIELDS_TIP')?>
		</div>
    </div>
    <tr>			
         <td>				
            <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_'.$this->configField['job']['caption'])); ?></label>			
         </td>		
         <td>				
             <div class='f-left'><?php echo $this->lists['job_prefix']; ?><b style="color: #FF0000 ; padding: 0px 5px ;">*</b></div>	
             <div id="fl_job_prefix" class='f-left' <?php if($this->data->job_prefix != 'other'){ echo "style='display:none'" ; } ?> >                
             	<input type="text" maxlength="49" size="49"  style="width: 51%"
             		value="<?php echo $this->data->o_job_prefix; ?>" 
             		id="o_job_prefix" name="o_job_prefix" 
             		title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_OTHER_JOB_PREFIX_TIP')); ?>" 
             		class="has-tip tip-right noradius" />
             </div>
             <div class='f-left padding-left30'><?php echo $this->lists['job']; ?>
             	<b style="color: #FF0000 ; padding: 0px 5px ;">*</b>			
				<?php if(!empty($this->configField['job']['f_tip'])):?>					
					<span class="hint"><?php echo $this->configField['job']['f_tip']; ?>
	             	<span class="hint-pointer">&nbsp;</span></span>				
				<?php endif ; ?>				
             </div>	
             
             <div id="fl_o_job" class='f-left' <?php if($this->data->job != 'other'){ echo "style='display:none'" ; } ?> >                
             	<input type="text" maxlength="49" size="49"  style="width: 51%"
             		value="<?php echo $this->data->o_job; ?>" 
             		id="o_job" name="o_job" 
             		title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_Other')); ?>" 
             		class="has-tip tip-right noradius" />
             </div>			
         </td>		
    </tr>		
  	
    <tr>			
        <td>				
            <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_'.$this->configField['department']['caption'])); ?></label>			
        </td>				
        <td>				
            <?php echo $this->lists['department']; ?>				
            <?php if(!empty($this->configField['department']['f_tip'])):?>				
            <span class="hint"><?php echo $this->configField['department']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span>				<?php endif ;?>			
        </td>		
    </tr>		
    <tr id="fl_o_department" <?php if($this->data->department != 'other'){echo "style='display:none'" ; }?>>			
        <td colspan="2">				
            <table class="other eight">					
                <tr>						
                    <td>							
                        <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_Other')); ?></label>						
                    </td>
                    <td>							
                        <input type="text" maxlength="50" size="50" value="<?php echo $this->data->o_department ; ?>" id="o_department" name="o_department" title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_Other_DEPARTMENT_TIP')); ?>" class="has-tip tip-right noradius" />					
                    </td>					
                </tr>				
            </table>			
        </td>		
    </tr>		
    <tr>			
        <td>				
            <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_'.$this->configField['company_name']['caption'])); ?></label>			
        </td>			
        <td>				
            <input type="text" maxlength="54" size="54" value="<?php echo $this->data->company_name; ?>" id="company_name" name="company_name" title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_company_name_TIP')); ?>" class="five has-tip tip-right noradius" />				
            <b style="color: #FF0000 ; padding: 0px 5px ;">*</b>
            <?php if(!empty($this->configField['company_name']['f_tip'])):?>				
            <span class="hint"><?php echo $this->configField['company_name']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span> 				
            <?php endif ; ?>			
        </td>		
    </tr>		
    <tr>			
        <td>				
            <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_'.$this->configField['industry']['caption'])); ?></label>			
        </td>			
        <td>				
            <?php echo $this->lists['industry']; ?>				
            <?php if(!empty($this->configField['industry']['f_tip'])):?>				
            <span class="hint"><?php echo $this->configField['industry']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span>				
            <?php endif ; ?>			
        </td>
    </tr>
    
    <tr id="fl_o_industry" <?php if($this->data->industry != 'other'){echo "style='display:none'" ; }?>>			
        <td colspan="2">				
            <table class="other eight">					
                <tr>						
                    <td>							
                        <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_INDUSTRY_Other')); ?></label>						
                    </td>
                    <td>							
                        <input type="text" maxlength="50" size="50" value="<?php echo $this->data->o_industry ; ?>" id="o_industry" name="o_industry" title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_Other_INDUSTRY_TIP')); ?>" class="has-tip tip-right noradius" />					
                    </td>					
                </tr>				
            </table>			
        </td>		
    </tr>		
    
    		
    <tr>			
        <td>				
            <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_'.$this->configField['c_info']['caption'])); ?></label>			
        </td>			
        <td>				
            <input type="text" maxlength="54" size="54" value="<?php echo $this->data->c_info; ?>" id="c_info" name="c_info" title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_c_info_TIP')); ?>" class="five has-tip tip-right noradius" />				
            <?php if(!empty($this->configField['c_info']['f_tip'])):?>				
            <span class="hint"><?php echo $this->configField['c_info']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span> 				
            <?php endif ; ?>			
        </td>		
    </tr>		
    <tr>			
        <td>				
            <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_'.$this->configField['c_addr']['caption'])); ?></label>			
        </td>			
        <td>				
            <input type="text" maxlength="54" size="54" value="<?php echo $this->data->c_addr; ?>" id="c_addr" name="c_addr" title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_c_addr_TIP')); ?>" class="five has-tip tip-right noradius" />				
            <?php if(!empty($this->configField['c_addr']['f_tip'])):?>				
            <span class="hint"><?php echo $this->configField['c_addr']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span> 				
            <?php endif ;?>			
        </td>		
    </tr>		
    <tr>			
        <td>				
            <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_'.$this->configField['c_country']['caption'])); ?></label>			
        </td>			
        <td>				
            <?php echo $this->lists['country']; ?>				
            <?php if(!empty($this->configField['c_country']['f_tip'])):?>				
            <span class="hint"><?php echo $this->configField['c_country']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span>				
            <?php endif ; ?>			
        </td>		
    </tr>		
    <tr>			
        <td width="175">				
            <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_'.$this->configField['c_city']['caption'])); ?></label>			
        </td>
        <td>				
			<?php echo $this->lists['city']; ?>				
            <?php if(!empty($this->configField['c_city']['f_tip'])):?>				
            <span class="l-hint"><?php echo $this->configField['c_city']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span>				
            <?php endif ; ?>			
        </td>		
    </tr>		
    <tr>			
        <td>				
            <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP3_'.$this->configField['c_distric']['caption'])); ?></label>			
        </td>		
        <td>				
			<?php echo $this->lists['distric']; ?>				
            <?php if(!empty($this->configField['c_distric']['f_tip'])):?>				
            <span class="hint"><?php echo $this->configField['c_distric']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span>				
            <?php endif ;?>			
        </td>		
    </tr>		
    <tr>			
        <td colspan="2">				
            <input type="submit" value="<?php echo JText::_('WRD_PROFILE_SAVE_CONTINUE') ?>" onclick="document.getElementById('continue').value = 1" id="save_and_continue" name="save_and_continue" class="button_save_and_continue bt" />				
            <input type="submit" value="<?php echo JText::_('WRD_PROFILE_FINISH') ?>" id="finish" onclick="document.getElementById('continue').value = 0" name="finish" class="button_finish bt" />			
        </td>
	</tr>
</table>
</td>		
</tr>	
</table>
<input type="hidden" name="member_id" value="<?php echo $this->user_info->member_id; ?>" />	
<input type="hidden" id="continue" name="continue" value="">	
<input type="hidden" name="profile" value="<?php echo $this->data->id ?>">	
<input type="hidden" name="option" value="com_wrd">
<input type="hidden" name="task" value="profile.save">	
<?php echo JHtml::_('form.token');?></form>

</div>
</div>

<script type="text/javascript">
                    
	function checkForm(frm){
		
		if(frm.job_prefix.value == -1){
			alert('<?php echo JText::_('WRD_PROFILE_ALERT_PLEASE_SELECT_JOB_PREFIX') ?>');
			frm.job_prefix.focus();
			return false;
		}
		
		if(frm.job.value == 0 ){
			alert('<?php echo JText::_('WRD_PROFILE_ALERT_PLEASE_SELECT_JOB') ?>');
			frm.job.focus();
			return false;
		}
		
		if(frm.job.value == 'other' && frm.o_job.value == ''){
			alert('<?php echo JText::_('WRD_PROFILE_ALERT_PLEASE_SELECT_JOB') ?>');
			frm.job.focus();
			return false;
		}
		
		
        if(frm.company_name.value == "")
		{
			alert('<?php echo JText::_('WRD_PROFILE_ALERT_PLEASE_SUPPLY_YOUR_COMPANY_NAME') ?>');
			frm.company_name.focus();
			return false;
		}

	    return true;
	}
</script>

